<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/

/**
* Smarty function plugin
* -------------------------------------------------------------
* Type:     function
* Name:     randnum
* Author:   Rob Ruchte (rob care of elementcstudios dot com)
* Purpose:  returns a random whole number
* -------------------------------------------------------------
* @param int floor optional lower range limit (defaults to 0)
* @param int ceiling optional upper range limit (defaults to 1000)
* @return int
*/
function smarty_function_random($params, &$smarty)
{
    $floor = (array_key_exists('floor', $params)) ? $params['floor']:0;
    $ceiling = (array_key_exists('ceiling', $params)) ? $params['ceiling']:1000;

    if($params['var']){
       $var = $params['var'];
    }else{
       $var = 'randnum';
    }

    $result = rand($floor, $ceiling);
    $smarty->assign($var, $params['prep'].$result);
}
?>